import React, { Component } from 'react'
import ReactDOM from 'react-dom/client'
import Childs from './Childs'
class App extends Component {
  state = {
    parent: '',
    sonwife: '',
  }
  render() {
    return (
      <div>
        <h1>我是App组件</h1>
        配偶：
        <input
          type='text'
          value={this.state.parent}
          onChange={this.handleChange}
        />
        <div>erxifu：{this.state.sonwife}</div>
        <hr />
        <Childs parent={this.state.parent} changeName={this.changeName}>
          {' '}
        </Childs>
      </div>
    )
  }
  handleChange = (e) => {
    this.setState({
      parent: e.target.value,
    })
  }
  changeName = (name) => {
    // console.log('接收到了', name),
    this.setState({
      sonwife: name,
    })
  }
}
const root = ReactDOM.createRoot(document.getElementById('root'))
root.render(<App />)
